Nested for


Nested for

It is possible to include a for inside another for. Each for, then, will have one variable to control its execution.
Es posible incluir un for dentro de otro for. Cada for, entonces, tendrá una variable para controlar su ejecución.

Problem 1
Compute the table of variables and the output of the code shown. Suppose there is a textbox called tbx1 with the property of multiline. In this case, the variable i takes the values of: 0, 1 and 2. For each value of i, the variable j will take the values: 0, 1 and 2. Create a dialog application using Wintempla called Sarahi.
Calcule la tabla de variables y la salida del código de abajo. Suponga que hay una caja de texto llamada tbx1 con la propiedad de multilínea. En este caso, la variable i toma los valores de: 0, 1 y 2. Por cada valor de i, la variable j tomará los valores de: 0, 1 y 2. Cree una aplicación de diálogo de Wintempla llamada Sarahi.

Sarahi.h

void Sarahi::Window_Open(Win::Event& e)
{
     wchar_t text[64];
     for(int i = 0; i < 3; i++)
     {
          for(int j = 0; j <= 2; j++)
          {
               _snwprintf_s(text, 64, _TRUNCATE, L"%d, %d\r\n", i, j);
               tbx1.Text += text;
          }
     }
}

vt_ittext

Problem 2
Compute the table of variables and the output of the code shown. Suppose there is a textbox called tbx1 with the property of multiline. In this case \t is used to insert a tab in the text.
Calcule la tabla de variables y la salida del código de abajo. Suponga que hay una caja de texto llamada tbx1 con la propiedad de multilínea. En este caso \t es usado para insertar un tabulador en el texto.

Sarahi.h

void Sarahi::Window_Open(Win::Event& e)
{
     wchar_t text[64];
     int i = 0;
     int j = 0;
     for(i = 1; i < 7; i += 2)
     {
          for(j = 0; j <= 5; j += 2)
          {
               _snwprintf_s(text, 64, _TRUNCATE, L"%d\t%d\r\n", i, j); // \t = tab
               tbx1.Text += text;
          }
     }
}

vt_ittext

Problem 3
Compute the table of variables and the output of the code shown. Suppose there is a textbox called tbx1 with the property of multiline.
Calcule la tabla de variables y la salida del código de abajo. Suponga que hay una caja de texto llamada tbx1 con la propiedad de multilínea.

Sarahi.h
void Sarahi::Window_Open(Win::Event& e)
{
     wchar_t text[64];
     int i = 0;
     int j = 0;
     for(i = 1; i < 10; i += 2)
     {
          for(j = 0; j < 7; j += 3)
          {
               _snwprintf_s(text, 64, _TRUNCATE, L"(%d, %d)\t\t", i, j);
               tbx1.Text += text;
          }
          tbx1.Text += L"\r\n";
     }
}

vt_ittext

© Copyright 2000-2021 Wintempla selo. All Rights Reserved. Jul 22 2021. Home